import React from 'react';
import ReactDOM from 'react-dom';

import Header from './components/Header';
import { Card, WhiteSpace } from 'antd-mobile';
import { Setting } from './components/Setting';

const App = React.createClass({
	getInitialState() {
    return {
    	data:{
    		enroll_year:'',
	    	notice:'',
	    	status:'',
	    	time:'',
	    	username:''
    	}
    }
  },
  render() {
    return (
    <div className="container" id="container">
      <Header title="资格审查" leftContent="" />
        <div>
        <WhiteSpace size="lg" />
        <div style={{ fontSize: '0.5rem', color: '#ccc', lineHeight: '2rem', textAlign: 'center' }}>暂无信息</div>
      </div>
    </div>
    );
    return (
    <div className="container" id="container">
				<Header title="资格审查" leftContent="" />

    	  <div>
		    <WhiteSpace size="lg" />
		    <Card full>
		      <Card.Header
		        title={"年度"+this.state.data.enroll_year}
		        extra={<span>研究生考试报名</span>}
		      />
		      <Card.Body>
		        <div>申请时间:<span>{this.state.data.time}</span></div>
		        <WhiteSpace/>
		        <div>申请状态:<span>{this.state.data.status}</span></div>
		      </Card.Body>
		      <WhiteSpace/>
		      <Card.Footer content={this.state.data.notice} />
		    </Card>
		  </div>
    </div>);
  },
  componentDidMount(){
  	const _this = this;
  	fetch( Setting.BaseUrl + 'result' , {
      credentials: 'include',
      method: 'GET',
      headers: {
        'Content-Type': 'application/json'
      }
    }).then( function(resp) {
      return resp.json();
    }).then( function(json) {
    	if(json.success){
    		_this.setState({
    			data:json.date
    		})
    	}
    })
  }
})

ReactDOM.render(<App />, document.getElementById('example'));
